import 'dart:convert';

import 'package:thinking/config/_.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/utils/_.dart';
import 'package:thinking/http/Dio.dart';
import 'package:dio/dio.dart';
class UserService{
  static Future<UserList> login({required Map<String,dynamic> params}) async{
    var res = await HttpApi().post(url: Config.apiUrl['ApiList']['login'],params: params,options:Options(extra:{'showLoading':true}));
    String decodeData = await Tool.decodeString(await Tool.rsaMain(),res['data'] );
    return UserList.fromJson(jsonDecode(decodeData));
  }
  static Future<dynamic> changeUserFollow({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['changeUserFollow'],params: params,options:Options(extra:{'showLoading':true}));
    return res;
  }
  static Future<UserData> getUserData({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['getUserData'],params: params,options:Options(extra:{'showLoading':false}));

    return UserData.fromJson(res['data']);
  }
  static Future<DynamicResult> getUserDynamic({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['getUserDynamic'],params: params,options:Options(extra:{'showLoading':false}));
    return DynamicResult.fromJson(res['data']);
  }
  static Future<UserListResult> getUserFollowOrFans({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['getUserFollowOrFans'],params: params,options:Options(extra:{'showLoading':false}));
    return UserListResult.fromJson(res['data']);
  }
  static Future<DynamicResult> getPersonalDynamicList({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['getPersonalDynamicList'],params: params,options:Options(extra:{'showLoading':false}));
    return DynamicResult.fromJson(res['data']);
  }
  static Future<HomeResult> getPersonalThinkList({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['getPersonalThinkList'],params: params,options:Options(extra:{'showLoading':false}));
    return HomeResult.fromJson(res['data']);
  }
  static Future<dynamic> updateUserData({required Map<String,dynamic> params}) async{
    var res = await HttpApi().get(url: Config.apiUrl['ApiList']['updateUserData'],params: params,options:Options(extra:{'showLoading':true}));
    return res['data'];
  }

}